<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Index</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <style type="text/css">
        html,
        body {
            height: 100%;
        }

        #wrap {
            height: 100%;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-flex-flow: column;
        }

        .kz-header {
            text-align: center;
            color: #81B846;
            width: 100%;
            min-height: 43px;
            display: flex;
            justify-content: space-between;
        }

        .kz-header .kz-header-btn-left {
            width: 22px;
            height: 22px;
            margin-left: 10px;
            margin-top: 6px;
            padding: 4px;
        }

        .kz-header .kz-header-btn-right {
            width: 22px;
            height: 22px;
            margin-right: 10px;
            margin-top: 6px;
            padding: 4px;
        }

        .kz-header img {
            width: 100%;
        }

        .kz-header .kz-header-main-tab {
            width: 210px;
            margin-top: 6px;
            line-height: 30px;
            font-size: 1.05rem;
        }

        .kz-header .kz-header-main-tab ul {
            position: relative;
        }

        .kz-header .kz-header-main-tab ul .kz-header-main-tab-active-bar {
            position: absolute;
            left: 8px;
            top: 27px;
            width: 54px;
            height: 2px;
            border-radius: 1px;
            background-color: #81B846;
            display: block;
            transition: all .3s;
        }

        .kz-header .kz-header-main-tab li {
            float: left;
            width: 70px;
            height: 30px;
            line-height: 30px;
            color: #81B846;
            font-size: 1rem;
            transition: all .05s;
        }

        .kz-header .kz-header-main-tab li.active {
            transform: scale(1.08);
        }

        #main {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
        }

        .con {
            font-size: 28px;
            text-align: center;
        }
    </style>
</head>

<body>
  <div id="wrap">
      <div class="kz-header" id="header-main">
          <div class="kz-header-btn-left" tapmode onclick="mainSearchOnclick()">
              <img src="./image/main/nav_icon_search.png">
          </div>
          <div class="kz-header-main-tab" id="main-header-tab">
              <ul>
                  <li tapmode onclick="headerMenuOnclick(this)">管理员</li>
                  <li tapmode onclick="headerMenuOnclick(this)" style="font-size:1.2rem;" class="active">主机</li>
                  <li tapmode onclick="headerMenuOnclick(this)" >摄像头</li>
                  <div class="kz-header-main-tab-active-bar"></div>
              </ul>
          </div>
          <div class="kz-header-btn-right">
              <img src="./image/main/nav_icon_add.png">
          </div>
      </div>
      <div class="kz-header" id="header-course"  style="display:none;">
          <div class="kz-header-btn-left">
              <!-- <img src="./image/course/nav_icon_list.png"> -->
          </div>
          <div class="kz-header-main-tab">
              地图
          </div>
          <div class="kz-header-btn-right" tapmode onclick="menuCourseRightOnclick()">
              <!-- <img src="./image/course/nav_icon_add.png"> -->
          </div>
      </div>
      <div class="kz-header" id="header-circle"  style="display:none;">
          <div class="kz-header-btn-left">
              <img src="./image/main/list.png">
          </div>
          <div class="kz-header-main-tab">
              农事
          </div>
          <div class="kz-header-btn-right" tapmode onclick="onNewFarming()">
              <img src="./image/main/edit.png">
          </div>
      </div>
      <div class="kz-header" id="header-circle"  style="display:none;">
          <div class="kz-header-btn-left">
              <img src="">
          </div>
          <div class="kz-header-main-tab">
              我的
          </div>
          <div class="kz-header-btn-right">
              <img src="./image/main/nav_icon_setting.png">
          </div>
      </div>
      <div class="kz-header" id="header-circle"  style="display:none;">
          <div class="kz-header-btn-left">
              <img src="">
          </div>
          <div class="kz-header-main-tab">
              我
          </div>
          <div class="kz-header-btn-right">
              <img src="./image/me/nav_icon_setting.png">
          </div>
      </div>
      <div id="main">

      </div>
  </div>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    apiready = function() {
      checkLogin();
      var header = $(".kz-header").get(0);
      $(".kz-header").each(function(){
          $api.fixStatusBar(this);
      });
        var headerH = $api.offset(header).h;
        var frameH = api.winHeight - headerH;
        api.openFrameGroup({
            name: 'main_group',
            rect: {
                x: 0,
                y: headerH,
                w: 'auto',
                h: frameH
            },
            frames: [{
                name: 'main_follow',
                url: './html/managerList.html',
                bgColor: '#fff',
                bounces: true
            }, {
                name: 'main',
                url: './html/engineList.html',
                bgColor: '#fff',
                bounces: true
            }, {
                name: 'main_activity',
                url: './html/monitorList.html',
                bgColor: '#fff',
                bounces: true
            }, {
                name: 'map',
                url: './html/map.html',
                bgColor: '#fff',
                bounces: true,
                useWKWebView: true
            }, {
                name: 'farming',
                url: './html/farmingList.html',
                bgColor: '#fff',
                bounces: true
            }, {
                name: 'message',
                url: './html/me.html',
                bgColor: '#F2F4F5',
                bounces: true
            }, {
                name: 'me',
                url: './html/me.html',
                bgColor: '#F2F4F5',
                bounces: true
            }],
            index: 1
        }, function(ret, err) {
            var index = ret.index;
            api.execScript({
                frameName: 'footer',
                script: 'setActive(' + index + ');'
            });
            if (index < 3) {
                setHeaderMenuActive(index);
            }
            setHeader(index);
        });
        api.openFrame({
            name: 'footer',
            url: './html/footer.html',
            rect: {
                x: 0,
                y: api.winHeight - 55,
                w: 'auto',
                h: 'auto'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: false,
            hScrollBarEnabled: false
        });
    };

    function headerMenuOnclick(el) {
        var index = $("#main-header-tab li").index(el);
        setHeaderMenuActive(index);
        api.setFrameGroupIndex({
            name: 'main_group',
            index: index,
            scroll: true
        });

    }

    function setHeaderMenuActive(index) {
        $("#main-header-tab li").removeClass("active");
        $("#main-header-tab li").eq(index).addClass("active");
        $(".kz-header-main-tab-active-bar").css("left", (8 + 70 * (index)) + "px"); //58;

    }

    function setHeader(index) {
        if (index <= 2) {
            index = 0;
        } else {
            index = index - 2;
        }
        $(".kz-header").hide();
        var header = $(".kz-header").get(index);
        if (header) {
            $(header).show();
        }
    }


    function onNewFarming(){
      api.openWin({
          name: 'newFarming',
          url: './html/farming/newFarming_win.html'
      });
    }

    function checkLogin(){
      api.openWin({
          name: 'login',
          url: './html/user/login.html'
      });

    }
</script>

</html>
